// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Inference;

[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.Json.ContextualAITaskSettingsConverter))]
public sealed partial class ContextualAITaskSettings
{
#if NET7_0_OR_GREATER
	public ContextualAITaskSettings()
	{
	}
#endif
#if !NET7_0_OR_GREATER
	public ContextualAITaskSettings()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal ContextualAITaskSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	/// <summary>
	/// <para>
	/// Instructions for the reranking model. Refer to <a href="https://docs.contextual.ai/api-reference/rerank/rerank#body-instruction">https://docs.contextual.ai/api-reference/rerank/rerank#body-instruction</a>
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public string? Instruction { get; set; }

	/// <summary>
	/// <para>
	/// Whether to return the source documents in the response.
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public bool? ReturnDocuments { get; set; }

	/// <summary>
	/// <para>
	/// The number of most relevant documents to return.
	/// If not specified, the reranking results of all documents will be returned.
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public int? TopK { get; set; }
}

public readonly partial struct ContextualAiTaskSettingsDescriptor
{
	internal Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public ContextualAiTaskSettingsDescriptor(Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings instance)
	{
		Instance = instance;
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public ContextualAiTaskSettingsDescriptor()
	{
		Instance = new Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
	}

	public static explicit operator Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor(Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings instance) => new Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings(Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// Instructions for the reranking model. Refer to <a href="https://docs.contextual.ai/api-reference/rerank/rerank#body-instruction">https://docs.contextual.ai/api-reference/rerank/rerank#body-instruction</a>
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor Instruction(string? value)
	{
		Instance.Instruction = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Whether to return the source documents in the response.
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor ReturnDocuments(bool? value = true)
	{
		Instance.ReturnDocuments = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The number of most relevant documents to return.
	/// If not specified, the reranking results of all documents will be returned.
	/// Only for the <c>rerank</c> task type.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor TopK(int? value)
	{
		Instance.TopK = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings Build(System.Action<Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor>? action)
	{
		if (action is null)
		{
			return new Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance);
		}

		var builder = new Elastic.Clients.Elasticsearch.Inference.ContextualAiTaskSettingsDescriptor(new Elastic.Clients.Elasticsearch.Inference.ContextualAITaskSettings(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}
}